home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / J A V A / Java Development Kit V1.2 / jdk12-win32(1).exe / data1.cab / demos / demo / jfc / SwingApplet / SwingApplet.java < prev   
Encoding:
Java Source  |  1998-12-01  |  1.5 KB  |  57 lines

  1. /*
  2.  * @(#)SwingApplet.java    1.11 98/08/26
  3.  *
  4.  * Copyright 1997, 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. import java.awt.*;
  16. import java.awt.event.*;
  17. import java.net.*;
  18. import java.applet.*;
  19. import javax.swing.*;
  20.  
  21. /**
  22.  * A very simple applet.
  23.  */
  24. public class SwingApplet extends JApplet {
  25.  
  26.     JButton button;
  27.  
  28.     public void init() {
  29.  
  30.     // Force SwingApplet to come up in the System L&F
  31.     String laf = UIManager.getSystemLookAndFeelClassName();
  32.     try {
  33.         UIManager.setLookAndFeel(laf);
  34.         // If you want the Cross Platform L&F instead, comment out the above line and
  35.         // uncomment the following:
  36.         // UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
  37.     } catch (UnsupportedLookAndFeelException exc) {
  38.         System.err.println("Warning: UnsupportedLookAndFeel: " + laf);
  39.     } catch (Exception exc) {
  40.         System.err.println("Error loading " + laf + ": " + exc);
  41.     }
  42.  
  43.         getContentPane().setLayout(new FlowLayout());
  44.         button = new JButton("Hello, I'm a Swing Button!");
  45.         getContentPane().add(button);
  46.     }
  47.  
  48.     public void stop() {
  49.         if (button != null) {
  50.             getContentPane().remove(button);
  51.             button = null;
  52.         }
  53.     }
  54. }
  55.  
  56.  
  57.